﻿function hide(){
    document.getElementById("hbg").style.display="none";
    document.getElementById("alertM").style.display="none";
}

function checkLogin(form){
    if (form.username.value == "") {
        document.getElementById("alertP").innerHTML="请输入用户名！";
        document.getElementById("hbg").style.display="block";
        document.getElementById("alertM").style.display="block";
        return false;
    }
    else if (!/^(\w){6,16}$/.exec(form.password.value)) {
        document.getElementById("alertP").innerHTML="密码格式输入有误，请正确输入6~16位英文数字下划线组合！";
        document.getElementById("hbg").style.display="block";
        document.getElementById("alertM").style.display="block";
        form.password.value = "";
        return false;
    }
    else {
        return true;
    }
}

function checkRegister(form){
    if (!(/^1\d{10}$/.test(form.phone.value))) {
        document.getElementById("alertP").innerHTML="手机号格式有误，请重新输入！";
        document.getElementById("hbg").style.display="block";
        document.getElementById("alertM").style.display="block";
        form.phone.value = "";
        return false;
    }
    else if (!/^(\w){6,16}$/.exec(form.reg_password.value)) {
        document.getElementById("alertP").innerHTML="密码格式输入有误，请正确输入6~16位英文数字下划线组合！";
        document.getElementById("hbg").style.display="block";
        document.getElementById("alertM").style.display="block";
        form.reg_password.value = "";
        form.reg_password2.value = "";
        return false;
    }
    else if (form.reg_password.value != form.reg_password2.value) {
        document.getElementById("alertP").innerHTML="两次密码输入不一致，请重新输入！";
        document.getElementById("hbg").style.display="block";
        document.getElementById("alertM").style.display="block";
        form.reg_password.value = "";
        form.reg_password2.value = "";
        return false;
    }
    else {
        return true;
    }
}
